package com.xuzz.xrpc.registry;

import com.xuzz.xrpc.common.ConfigManager;
import com.xuzz.xrpc.common.PropertyConfig;

import java.util.List;

/**
 */
public class RedisRegistry extends AbstractRegistrar {

    public void register(String service) {
        RedisOparetor.getJedis().lpush(FOLDER + SEPARATOR + service, ConfigManager.propertyConfig.getServerAddress());
    }

    @Override
    protected void init(String address) {
        RedisOparetor.init(address);
    }

    @Override
    public List<String> lookup(String service) {
        List<String> lrange = RedisOparetor.getJedis().lrange(FOLDER + SEPARATOR + service, 0, -1);
        return lrange;
    }
}
